#include "front/text_normalize.h"

using namespace std;
using namespace ppspeech;

const wregex mcWregexPercent(L"(-?)(\\d+(\\.\\d+)?)(\\s*)%");

// 百分数，例如：45.5% --> 百分之四十五点五
void TextNormalizer::TnRePercentage(wstring* fpInWsentence, const LanguageEnum fcInLanguage)
{
	wsmatch tWsmatch;

	while (regex_search(*fpInWsentence, tWsmatch, mcWregexPercent)) {
		string tStrPercent = wstring2utf8string(tWsmatch[0]);		//匹配到百分号的字符串

		StrReplace(tStrPercent, " ", "");

        string tStrReplace = ReplaceMethod(vector<string>{tStrPercent}, (fcInLanguage==LANG_EN)?RME_en_percent:RME_zh_percent);

		WstrReplacePosition(fpInWsentence, tWsmatch.position(0), tWsmatch.length(0), utf8string2wstring(tStrReplace));
	}
}
